import { Controller, Get, Post, Body, HttpCode, Query } from '@nestjs/common';
import { CategoryService as Service } from '../services/category.service';

@Controller('category')
export class CategoryController {
  constructor(private readonly service: Service) { }

  /**
   * 查询列表
   * @param query
   */
  @Get()
  async getAll(@Query() query): Promise<any> {
    return this.service.findAll(query);
  }

  /**
   * 按Type查询列表
   * @param query
   */
  @Post('/findAllByType')
  async getAllByType(@Body() body): Promise<any> {
    return this.service.findAllByType(body);
  }

  /**
   * 添加
   */
  @Post('/add')
  async add(@Body() body): Promise<any> {
    return this.service.add(body);
  }

  /**
   * 修改
   */
  @Post('/update')
  async update(@Body() body): Promise<any> {
    return this.service.update(body);
  }

  /**
   * 删除
   */
  @Post('/delete')
  async delete(@Body() body): Promise<any> {
    return this.service.delete(body);
  }
}
